home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Ripple.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  4.2 KB  |  151 lines

  1. /*
  2. ** $VER: Ripple.ieb 1.11, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 2/2 1997 Stockholm/Sweden
  6. **
  7. ** Ripple image.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   Xoff=128 ; Yoff=128 ; Amplitude=32 ; Period=32 ; Phase=0 ; Radius=128
  42.  
  43.   if command ~= '' then parse var command Xoff Yoff Amplitude Period Phase '#'RipType '#'CalcType '#'LimitRip Radius
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Bulge" " OK | Cancel "',
  48.   ' INTEGER,"X offset",0,4096,'Xoff',SLIDER',
  49.   ' INTEGER,"Y offset",0,4096,'Yoff',SLIDER',
  50.   ' INTEGER,"Wave amplitude",0,359,'Amplitude',SLIDER',
  51.   ' INTEGER,"Period",0,4096,'Period',SLIDER',
  52.   ' INTEGER,"Phase",0,3600,'Phase',SLIDER'
  53.  
  54.   if command = '' then form = form||' CYCLE,"Ripple spread:","Around center|Out from center",0',
  55.     ' CHECKBOX,"Use attenuated (radius limited) ripple?",0'
  56.  
  57.   form = form||' INTEGER,"Wave radius",0,4096,'Radius',SLIDER'
  58.  
  59.   if command = '' then do
  60.     form = form||' CYCLE,"Type:","Best|Fast",0'
  61.  
  62.     form
  63.     parse var result ok Xoff Yoff Amplitude Period Phase RipType LimitRip Radius CalcType .
  64.     if ok = 0 then return '<ERROR>'
  65.  
  66.     if CalcType=0 then CalcType='BEST'
  67.     else CalcType = 'FAST'
  68.   end
  69.   else do
  70.     form
  71.     parse var result ok Xoff Yoff Amplitude Period Phase Radius .
  72.     if ok = 0 then return '<ERROR>'
  73.  
  74.     RipType = 'none'
  75.     CalcType = 'none'
  76.     LimitRip = 'none'
  77.   end
  78.  
  79.   back = Xoff Yoff Amplitude Period Phase '#'RipType '#'CalcType '#'LimitRip Radius
  80. return back
  81.  
  82. /* Required "Process_image" procedure  ------------------------------- */
  83.  
  84. process_image:
  85.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  86.   parse var options Xoff Yoff Amplitude Period Phase '#'RipType '#'CalcType '#'LimitRip Radius .
  87.  
  88.   'OPEN' '"'src_image'"' '24'
  89.   if (RC ~= 0) then do
  90.     'IE_TO_FRONT'
  91.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  92.     return '<ERROR>'
  93.   end
  94.   else LoadImage = result
  95.  
  96.   'PROJECT_INFO' LoadImage 'WIDTH'    /* Get width of image */
  97.   IW = RESULT
  98.   'PROJECT_INFO' LoadImage 'HEIGHT'    /* Get height of image */
  99.   IH = RESULT
  100.  
  101.   if Xoff >= (IW-1) then Xoff = (IW-1)
  102.   if Yoff >= (IH-1) then Yoff = (IH-1)
  103.   if Period > max(IW,IH) then Period = max(IW,IH)
  104.   if Radius > max(IW,IH) then Radius = max(IW,IH)
  105.  
  106.   do until ((Phase < 360)&(Phase >= 0))
  107.     if Phase > 359 then Phase = Phase - 360
  108.     if Phase < 0 then Phase = Phase + 360
  109.   end
  110.  
  111.   if LimitRip ~= 1 then Radius = ''
  112.   if RipType = 0 then RipType = 'AROUND'
  113.   else RipType = 'OUT'
  114.  
  115.   'RIPPLE' LoadImage Xoff Yoff Amplitude Period Phase RipType CalcType Radius
  116.   OutputImage = result
  117.   'CLOSE' LoadImage
  118.  
  119.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  120.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  121.   if (RC ~= 0) then do
  122.     'IE_TO_FRONT'
  123.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  124.     return '<ERROR>'
  125.   end
  126.   'CLOSE' OutputImage
  127.  
  128.   back = 'OK'
  129. return back
  130.  
  131. /* Internal procedures  ---------------------------------------------- */
  132.  
  133. /*******************************************************************/
  134. /* This is where control goes when an error code is returned by IE */
  135. /* It puts up a message saying what happened and on which line     */
  136. /*******************************************************************/
  137.  
  138. error:
  139. if RC=5 then do
  140.     IE_TO_FRONT
  141.     LAST_ERROR
  142.     'REQUEST "'||RESULT||'"'
  143. end
  144. else do
  145.     IE_TO_FRONT
  146.     LAST_ERROR
  147.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  148. end
  149.  
  150. return '<ERROR>'
  151.